package com.jmb.service.impl;

import com.jmb.dao.UserDao;
import com.jmb.po.UserInformation;
import com.jmb.service.UserService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class UserServiceImpl implements UserService {

    @Resource
    private UserDao userDao;

    @Override
    public UserInformation findByTel(String tel) {
        return userDao.findByTel(tel);
    }

    @Override
    public List<UserInformation> findAll() {
        return userDao.findAll();
    }

    @Override
    public boolean addUser(UserInformation user) {
        if (userDao.findByTel(user.getTel()) != null){
            return false;
        }
        return userDao.addUser(user)>0;
    }

    @Override
    public boolean delUser(String tel) {
        return userDao.delUser(tel)>0;
    }

    @Override
    public boolean updateUser(UserInformation user) {
        return userDao.updateUser(user)>0;
    }

    @Override
    public UserInformation findById(Integer id) {
        return userDao.findById(id);
    }

    @Override
    public UserInformation findTelAndPass(String tel, String password) {
        return userDao.findTelAndPass(tel,password);
    }
}
